home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / DEMO_APP / MAIL_TES.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  8.8 KB  |  252 lines

  1. package sub_arctic.demo_apps;
  2.  
  3. import sub_arctic.lib.*;
  4. import sub_arctic.input.*;
  5. import sub_arctic.output.*;
  6. import sub_arctic.constraints.std_function;
  7.  
  8. import java.util.Vector;
  9.  
  10. /**
  11.  * This is a demo applet for how a mailer might work/look in sub_arctic.
  12.  */
  13. public class mail_test extends debug_interactor_applet {
  14.   /* from box */
  15.   listbox from;
  16.   /* subject box */
  17.   listbox subject;
  18.   /* date box */
  19.   listbox date;
  20.   /* menubar */
  21.   menubar bar;
  22.   /* the vertical scrollbar */
  23.   v_scrollbar sbar;
  24.   /* the list of things to do */
  25.   listbox todo_list;
  26.   /*
  27.    * These two base_parent_interactors are the two big sections of
  28.    * the interface. top_section is the top part of the interface with
  29.    * the listboxes, bot_section is the botom part with the messges.
  30.    */
  31.   base_parent_interactor top_section, bot_section, list_section;
  32.   /**
  33.    * This function returns the interactor that is the playing field
  34.    * where all the messages get displayed.
  35.    */
  36.   public interactor playing_field() { return bot_section;}
  37.   /*
  38.    * The messages
  39.    */
  40.   Vector msg;
  41.  
  42.   /* 
  43.    * Data Structure Setup
  44.    */
  45.   public void pre_build_ui() {
  46.     /* for now, just fetch a vector of message objects */
  47.     msg=message.retreive_messages();
  48.   }
  49.   /**
  50.    * Initialize top section of the interface
  51.    */
  52.   public void build_top_section(base_parent_interactor top) {
  53.     /* we will override the size in a second with constraints */
  54.     top_section=new base_parent_interactor(0,0,10,10); 
  55.     /* constraint to be the size of the top level interface and
  56.      * to be as tall as the separator allows
  57.      */
  58.     top_section.set_w_constraint(std_function.offset(PARENT.W(),0));
  59.     top_section.set_h_constraint(std_function.fill(ZERO, NEXT_SIBLING.Y(),0));
  60.     /* put it into the top level */
  61.     top.add_child(top_section);
  62.     /* now build the sub_interactors */
  63.       from=new header_listbox(false,this);
  64.       subject=new header_listbox(false,this);
  65.       date=new header_listbox(false,this);
  66.       sbar=new listbox_v_scrollbar(from);
  67.       separator sep1=new separator(9,10/* constrained later*/,true), 
  68.     sep2=new separator(9, 10/* constrained later */,true);
  69.  
  70.       /* layout constraints on listboxes */ 
  71.       from.set_x_constraint(std_function.offset(PREV_SIBLING.X2(),0));
  72.       from.set_y_constraint(std_function.offset(ZERO,0));
  73.       from.set_w_constraint(std_function.fill(PREV_SIBLING.X2(),
  74.                        NEXT_SIBLING.X(),0));
  75.       from.set_h_constraint(std_function.offset(PARENT.H(),0));
  76.  
  77.       subject.set_x_constraint(std_function.offset(PREV_SIBLING.X2(),0));
  78.       subject.set_y_constraint(std_function.offset(ZERO,0));
  79.       subject.set_w_constraint(std_function.fill(PREV_SIBLING.X2(),
  80.                           NEXT_SIBLING.X(),0));
  81.       subject.set_h_constraint(std_function.offset(PARENT.H(),0));
  82.  
  83.       date.set_x_constraint(std_function.offset(PREV_SIBLING.X2(),0));
  84.       date.set_y_constraint(std_function.offset(ZERO,0));
  85.       date.set_w_constraint(std_function.fill(PREV_SIBLING.X2(),
  86.                           PARENT.X2(),0));
  87.       date.set_h_constraint(std_function.offset(PARENT.H(),0));
  88.  
  89.       /* we don't want any space around our objects other than the bevel */
  90.       from.set_left_space(0);
  91.       subject.set_left_space(0);
  92.       date.set_left_space(0);
  93.       from.set_right_space(0);
  94.       subject.set_right_space(0);
  95.       date.set_right_space(0);
  96.  
  97.       /* constrain the separators to size appropriately in Y */
  98.       sep1.set_y_constraint(std_function.offset(PREV_SIBLING.Y(),0));
  99.       sep1.set_h_constraint(std_function.offset(PREV_SIBLING.H(),0));
  100.       sep2.set_y_constraint(std_function.offset(PREV_SIBLING.Y(),0));
  101.       sep2.set_h_constraint(std_function.offset(PREV_SIBLING.H(),0));
  102.  
  103.       /* initialize the position of each sep */
  104.       sep1.set_x(250);
  105.       sep2.set_x(575);
  106.       /* take out the vertical scrollbars */
  107.       from.set_vertical_status(listbox_display.SCROLLBAR_NEVER);
  108.       subject.set_vertical_status(listbox_display.SCROLLBAR_NEVER);
  109.       date.set_vertical_status(listbox_display.SCROLLBAR_NEVER);
  110.       /* make these objects be in a group */
  111.       from.add_to_group(date);
  112.       subject.add_to_group(date);
  113.       /* constrain our own scrollbar */
  114.       sbar.set_y_constraint(std_function.offset(PARENT.Y(),3));
  115.       sbar.set_h_constraint(std_function.offset(NEXT_SIBLING.H(),-6));
  116.       sbar.set_x_constraint(std_function.offset(ZERO,5));
  117.       /* make our scrollbar control the first one */
  118.       from.set_external_v_scrollbar(sbar);
  119.       /* add everybody */
  120.       top_section.add_child(sbar); /* must be first */
  121.       top_section.add_child(from);
  122.       /* add the first separator */
  123.       top_section.add_child(sep1);
  124.       top_section.add_child(subject);
  125.       /* add the second separator */
  126.       top_section.add_child(sep2);
  127.       top_section.add_child(date);
  128.   }
  129.   /**
  130.    * Build the bottom section of the interface.
  131.    */
  132.   public void build_bottom_section(base_parent_interactor top) {
  133.     base_parent_interactor bot_parent;
  134.     label l;
  135.     /* build the interactor that will hold the two important
  136.      interactors */
  137.     bot_parent=new base_parent_interactor(0,0,10,10);
  138.     bot_parent.set_y_constraint(std_function.eq(PREV_SIBLING.Y2()));
  139.     bot_parent.set_w_constraint(std_function.eq(PARENT.W()));
  140.     bot_parent.set_h_constraint(std_function.fill(PREV_SIBLING.Y2(),
  141.                            PARENT.Y2(),10));
  142.     top.add_child(bot_parent);
  143.     
  144.     /* build the list section */
  145.     list_section=new base_parent_interactor(0,0,10,10); /* override these */
  146.     list_section.set_x_constraint(std_function.offset(PARENT.X(),1));
  147.     list_section.set_h_constraint(std_function.offset(PARENT.H(),0));
  148.     list_section.set_w_constraint(std_function.eq(MAX_CHILD.W()));
  149.     bot_parent.add_child(list_section);
  150.     /* put the list and label in */
  151.     l=new label("To Do List");
  152.     l.set_x_constraint(std_function.centered(PARENT.W(),0));
  153.     l.set_y(5);
  154.     list_section.add_child(l);
  155.     todo_list=new todo_listbox(this);
  156.     todo_list.set_x(0);
  157.     todo_list.set_y_constraint(std_function.eq(PREV_SIBLING.Y2()));
  158.     todo_list.set_h_constraint(std_function.fill(PREV_SIBLING.Y2(),
  159.                           PARENT.Y2(),0));
  160.     list_section.add_child(todo_list);
  161.  
  162.     /* we are going to override the y position and the height & width
  163.        with constraints */
  164.     bot_section=new base_parent_interactor(0,0,10,10);
  165.     bot_section.set_x_constraint(std_function.eq(PREV_SIBLING.X2()));
  166.     bot_section.set_w_constraint(std_function.fill(PREV_SIBLING.X2(),
  167.                         PARENT.X2(),0));
  168.     bot_section.set_h_constraint(std_function.eq(PARENT.H()));
  169.  
  170.     bot_parent.add_child(bot_section);
  171.   }
  172.   /**
  173.    * Initialize UI after build.
  174.    */
  175.   public void post_build_ui(base_parent_interactor top) {
  176.     int i;
  177.     message m;
  178.     Vector from_line=new Vector(), subject_line=new Vector(), date_line=new Vector();
  179.     
  180.     /* from line */
  181.     for (i=0; i<msg.size(); ++i) {
  182.       /* get the message out */
  183.       m=(message)msg.elementAt(i);
  184.       /* copy */
  185.       m=m.copy(); 
  186.       /* set the display property */
  187.       m.set_display_field(0);
  188.       from_line.addElement(new object_list_element(m));
  189.     }
  190.     /* subject line */
  191.     for (i=0; i<msg.size(); ++i) {
  192.       /* get the message out */
  193.       m=(message)msg.elementAt(i);
  194.       /* copy */
  195.       m=m.copy(); 
  196.       /* set the display property */
  197.       m.set_display_field(2);
  198.       subject_line.addElement(new object_list_element(m));
  199.     }
  200.     /* date line */
  201.     for (i=0; i<msg.size(); ++i) {
  202.       /* get the message out */
  203.       m=(message)msg.elementAt(i);
  204.       /* copy */
  205.       m=m.copy(); 
  206.       /* set the display property */
  207.       m.set_display_field(1);
  208.       date_line.addElement(new object_list_element(m));
  209.     }
  210.     /* put in the boxes */
  211.     from.set_contents(from_line);
  212.     subject.set_contents(subject_line);
  213.     date.set_contents(date_line);
  214.   }
  215.   /*
  216.    * Construct the user interface
  217.    */
  218.   public void build_ui(base_parent_interactor top) {
  219.     separator y_sep=new separator(10 /* constrained later */,9,false);
  220.     build_top_section(top);
  221.     /* put in the vertical separator */
  222.     y_sep.set_x(0);
  223.     y_sep.set_y(160);
  224.     y_sep.set_w_constraint(std_function.offset(PARENT.W(),0));
  225.     top.add_child(y_sep);
  226.     /* put in the bottom area */
  227.     build_bottom_section(top);
  228.   }
  229.   /**
  230.    * Return the todo_listbox that is in use.
  231.    */
  232.   public interactor todo_listbox() {
  233.     return todo_list;
  234.   }
  235. }
  236. /*=========================== COPYRIGHT NOTICE ===========================
  237.  
  238. This file is part of the subArctic user interface toolkit.
  239.  
  240. Copyright (c) 1996 Scott Hudson and Ian Smith
  241. All rights reserved.
  242.  
  243. The subArctic system is freely available for most uses under the terms
  244. and conditions described in 
  245.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  246. and appearing in full in the lib/interactor.java source file.
  247.  
  248. The current release and additional information about this software can be 
  249. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  250.  
  251. ========================================================================*/
  252.